{extend name="admin@public/basic" /}

{block name="style"}
<link rel="stylesheet" href="__STATIC__/css/admin/public.css" media="all"/>
{/block}

{block name="cotent"}
<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form">
            <input type="hidden" id="app_sn" value="{$app_sn}">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input device_no" placeholder="请输入设备号"/>
                </div>
                <a class="layui-btn search_btn" data-type="reload">搜索</a>
            </div>




        </form>
    </blockquote>
    <table id="userList" lay-filter="userList"></table>


</form>
{/block}

{block name="script"}
<script>
    layui.use(['laydate', 'form', 'layer', 'table', 'laytpl'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laytpl = layui.laytpl,
            table = layui.table,
            laydate = layui.laydate;

        //日期范围
        laydate.render({
            elem: '#create_at'
            , range: true
        });

        //用户列表
        var tableIns = table.render({
            elem: '#userList',
            // url: API_HOST + 'Boss/Company/getLists',
            url: '/Api/Equipment/getLists',
            method: 'POST',
            contentType: 'application/json; charset=UTF-8',
            headers: {
                "token": 'bbbbb'
            },
            where:{app_sn:$("#app_sn").val()},
            cellMinWidth: 95,
            page: true,
            height: "full-125",
            limits: [10, 15, 20, 25],
            limit: 20,
            id: "userListTable",
            request: {
                limitName: 'pageSize', //每页数据量的参数名，默认：limit
            },
            cols: [[
                {field: 'equipment_id', title: '设备ID', minWidth: 50, align: "center"},
                {field: 'device_no', title: '设备号', minWidth: 200, align: "center"},
                {field: 'service_time', title: '服务时间', minWidth: 200, align: 'center'},
                {field: 'address', title: '设备地址', align: 'center'},
            ]]
        });

        //搜索【此功能需要后台配合，所以暂时没有动态效果演示】
        $(".search_btn").on("click", function () {

            if ($(".searchVal").val() != '') {
                //执行重载
                table.reload('userListTable', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        //传参数
                        device_no: $(".device_no").val(),
                        app_sn: $("#app_sn").val(),
                    },

                });
                table.render();
                // layer.msg('查询成功');
            } else {
                layer.msg("请输入搜索的内容");
            }
        });

    })


</script>
{/block}
